{extend name="layout" /}


{block name="title"}任务领取{/block}

{block name="body"}
<span id="userId" hidden>{$userId}</span>
<a href="{:url('logout')}" class="layui-btn layui-btn-danger">退出登录</a>
<a href="{:url('myTask')}" class="layui-btn">我的任务</a>
<div style="width: 95%">
    <table id="task" lay-filter="demo" style="width: 50%"></table>
</div>

<script>
    layui.use('table', function(){
        const table = layui.table;
        let url = "{:url('getTask')}";
        let userId = $('#userId').text();
        table.render({
            elem: '#task'
            ,height: 600
            ,url: '/api/selfApi/getTaskList?userId='+userId //数据接口
            ,page: true //开启分页
            ,text :{
                none: '暂无发布任务'
            }
            ,cols: [[ //表头
                {field: 'task_name', title: '任务名', width:150, sort: true, fixed: 'left'}
                ,{field: 'task_lv', title: '任务等级', width:100}
                ,{field: 'task_profit', title: '任务收益', width:147, sort: true}
                ,{field: 'task_type', title: '任务类型', width:140}
                ,{field: 'task_description', title: '任务描述', width: 250}
                ,{field: 'task_total', title: '任务可领取总次数', width: 160, sort: true}
                ,{field: 'task_complete', title: '任务已领取总次数', width: 160, sort: true},
                {align: 'center', title: '操作', width: 100, templet: function (d) {
                    return '<a href="'+url+'?id='+d.id+'"  class="layui-btn layui-btn-sm" target="_self" " ">领取</a>';
                    }
                }
            ]],

        });

    });
</script>

{/block}